<?php
/**
 * Created by PhpStorm.
 * User: jocky
 * Date: 09/10/2017
 * Time: 13:04
 */
?>
<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_content">
            <div class="x_panel">
                <div class="x_title">
                    <h2><i>充值记录</i></h2>
                    <ul class="nav navbar-right panel_toolbox">
                        <li>
                            <a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                        </li>
                        <li onclick="rechargesObj.lists(3,0)">
                            <a href="javascript:void(0)"><i class="fa fa-refresh"></i></a>
                        </li>
                    </ul>
                    <div class="clearfix"></div>
                </div>
                <div class="x_content">
                    <form class="form-inline hide-or-show" id="recharge_history_search_form">
                        <div class="form-group" style="padding: 2px;">
                            <select name="status" class="form-control">
                                <option value="-1">充值状态 - 全部</option>
                                <option value="1">充值状态 - 请求中</option>
                                <option value="2">充值状态 - 成功</option>
                                <option value="3">充值状态 - 失败</option>
                                <option value="4">充值状态 - 已过期</option>
                            </select>
                        </div>

                        <div class="form-group" style="padding: 2px;">
                            <input name='p_clientSN' class="form-control" placeholder="客户编号"/>
                        </div>

                        <div class="form-group" style="padding: 2px;">
                            <input name="from"
                                   class="form-control datepicker"
                                   value="<?= date('Y-m-d', $from); ?>"
                                   placeholder="开始时间"/>
                        </div>

                        <div class="form-group" style="padding: 2px;">
                            <input name="to"
                                   class="form-control datepicker"
                                   value="<?= date('Y-m-d', $to); ?>"
                                   placeholder="结束时间"/>
                        </div>

                        <div class="form-group" style="padding: 2px;">
                            <button type="button" class="btn btn-sm btn-primary btn-block"
                                    onclick="rechargesObj.lists(1,1)">
                                查 询
                            </button>
                        </div>
                    </form>
                    <br/>
                    <div class="table-responsive">
                        <table class="table table-hover table-striped table-bordered" id="recharge_history_table">
                            <thead>
                            <tr>
                                <th>客户账号</th>
                                <th>姓名</th>
                                <th class="text-center">充值时间</th>
                                <th class="text-center">支付方式</th>
                                <th>状态</th>
                                <th class="text-right">金额</th>
                                <th class="text-right">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr>
                                <td><i style="color: red;">汇总</i></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td></td>
                                <td class='text-right'>
                                    <i>
                                        <?= number_format($sumMoney, 2, '.', ''); ?>
                                    </i>
                                </td>
                                <td></td>
                            </tr>
                            <?php
                            $str = "";
//                            var_dump($lists);
//                            exit();
                            foreach ($lists as $v) {
                                switch ($v['status']) {
                                    case 1:
                                        $status = "<label class='label label-default'>请求中</label>";
                                        break;
                                    case 2:
                                        $status = "<label class='label label-success'>成功</label>";
                                        break;
                                    case 3:
                                        $status = "<label class='label label-danger'>失败 | " . $v['resp_code'] . "</label>";
                                        break;
                                    case 4:
                                        $status = "<label class='label label-default'>已过期</label>";
                                        break;
                                    default:
                                        $status = "";
                                        break;
                                }
                                $str .= "<tr>";
                                $str .= "<td>
                                            <a href='javascript:void(0)' 
                                            title='查看 / 修改账户信息'
                                            onclick='traderObj.setForm(" . $v['userID'] . ")'>
                                            " . $v['loginName'] . "
                                            </a>
                                          </td>
                                ";
                                $str .= "<td>" . $v['accountName'] . "</td>";
                                $str .= "<td class='text-center'>" . date('Y-m-d H:i:s', $v['pay_start_time']) . "</td>";
                                $str .= "<td class='text-center'>" . ($v['type'] == 1 ? "快捷支付" : "网关支付") . "</td>";
                                $str .= "<td>" . $status . "</td>";
                                $str .= "<td class='text-right'>
                                            <i>" . (float)$v['money'] . "</i>
                                         </td>";
                                $str.="<td style='text-align: center;' onclick='rechargesObj.setForm(\"".$v['recharge_sn']."\")'><a>手动确认</a></td>";
                                $str .= "</tr>";
                            }

                            echo $str;
                            ?>
                            </tbody>
                        </table>
                    </div>

                    <div class="ln_solid"></div>

                    <form class="form-inline text-center">
                        <div class="form-group">
                            <button type="button" class="btn btn-sm btn-primary btn-block"
                                    onclick="rechargesObj.lists(1,1)">
                                &lt;&lt;
                            </button>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-sm btn-primary btn-block"
                                    onclick="rechargesObj.lists(2,1)">
                                &lt;
                            </button>
                        </div>
                        <div class="form-group">
                            <div class="input-group">
                                <span class="input-group-addon">
                                    共 <span id="recharge_history_pageTotal"><?= $pageTotal; ?></span> 页
                                </span>
                                <input type="number" min="1" class="form-control" id="recharge_history_pageNo"
                                       placeholder="请输入要跳转的页码"
                                       value="<?= $pageNo; ?>" style="text-align: center;"/>

                                <span class="input-group-btn">
                                    <button type="button" class="btn btn-primary btn-block"
                                            onclick="rechargesObj.lists(3,0)">
                                        翻 页
                                    </button>
                                </span>
                            </div>
                        </div>

                        <div class="form-group">
                            <button type="button" class="btn btn-sm btn-primary btn-block"
                                    onclick="rechargesObj.lists(2,2)">
                                &gt;
                            </button>
                        </div>
                        <div class="form-group">
                            <button type="button" class="btn btn-sm btn-primary btn-block"
                                    onclick="rechargesObj.lists(1,2)">
                                &gt;&gt;
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript" src="/js/recharges.js?v=<?= Yii::$app->params['version']; ?>"></script>
<script>
    $('#recharge_history_search_form .datepicker').datepicker({
        autoclose: true,
        format: "yyyy-mm-dd",
        todayHighlight: true
    });//时间插件重新初始化
</script>

